Closest Image

//Handler after imajnet was activated
ImajnetPlugin.onImajnetActivated = function() {
	//Set coordinates
	var lon = 19.04481154578742;
	var lat = 47.506274876770775; 	

	//Get closest image to this coordinates
	ImajnetPlugin.getClosestImage(lon, lat);
}

//Function that will get the closest image
ImajnetPlugin.getClosestImage = function(lon, lat) {
	//Set imajnet mode to closest image;
	Imajnet.activateImajnetControl(null, 'closestImage');

	//Pass the coordinates to the imajnet library
	ImajnetMap.mapClickHandler({
	    lon: lon,
	    lat: lat
	});
}

//Register events on the map to get oriented images on click
ImajnetPlugin.registerMapEvents = function() {
	map.on('click', onMapClick);
}

function onMapClick(event) {
	//all coordinates passed to the imajnet sdk must be in wgs84
	var coordinate = ol.proj.transform(event.coordinate, webMercator, wgs84);
	ImajnetPlugin.getClosestImage(coordinate[0], coordinate[1]);
}